﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>NFA</title>


        <script type="text/javascript" src="http://localhost:8080/nfa/js/jquery-2.1.1.min.js"></script>
        <link rel="stylesheet" type="text/css" href="http://localhost:8080/nfa/css/bootstrap.css" />
        <link rel="stylesheet" type="text/css" href="http://localhost:8080/nfa/css/style.css" />
        <link rel="stylesheet" type="text/css" href="http://localhost:8080/nfa/css/dropzone.css" />
        <link rel="stylesheet" type="text/css" href="http://localhost:8080/nfa/css/bootstrap-theme.css"  />
        <link rel="stylesheet" href="http://jqueryui.com/jquery-wp-content/themes/jqueryui.com/style.css"/>
        <link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css"/>
        <script src="//code.jquery.com/jquery-1.10.2.js"></script>
        <script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>

        <script type="text/javascript" src="http://localhost:8080/nfa/js/bootstrap.js"></script>

        <script type="text/javascript" src="http://localhost:8080/nfa/js/jquery.validate.js"></script>
        <script type="text/javascript" src="http://localhost:8080/nfa/js/messages_vi.js"></script>
        <script type="text/javascript" src="http://localhost:8080/nfa/js/js.js"></script>
        <script type="text/javascript" src="http://localhost:8080/nfa/js/popbox.js"></script>
        <script type="text/javascript" src="http://localhost:8080/nfa/js/dropzone.js"></script>
        <script type='text/javascript' charset='utf-8'>
            // document.getElementById("ob").scrollTop = 9999999;
            $(document).ready(function() {
                $('.popbox').popbox();
                $("#edit-stt").click(function() {
                    $("#stt").hide();
                    $("#form-stt").show();
                    $("#edit-stt").hide();
                });

                $("#frompicker").datepicker();
                $("#topicker").datepicker();
                $("#datepicker").datepicker();
            });
        </script>


    </head>
    <?php
    $image = $this->connect->getinfo($this->session->userdata("email"));
    foreach ($image as $i) {
        $anh = $i->avarta;
        $ten = $i->name;
        $truong = $i->education;
        $city = $i->city;
        $stt = $i->status;
        $cao = $i->height;
        $nang = $i->weight;
        $toi = $i->about_me;
        $ban = $i->about_you;
        $tim = $i->find_age;
        $mucdich = $i->target;
        $gt = $i->gender;
    }
    ?>
    <body onload="updateAlerts();
                updateconversations();
                updateRequest();
                getRequest();">

        <!-- header -->
        <header>
            <nav class="navbar navbar-fixed-top navbar-default" role="navigation" style="height:50px !important ; ">
                <div class="center">	
                    <div class="container-fluid">
                        <!-- Brand and toggle get grouped for better mobile display -->
                        <div class="navbar-header" style="width: 8%;">

                            <a class="navbar-brand" href="#" style=" font-size:30px; color:#F06; ;">NFA</a>
                        </div>

                        <!-- Collect the nav links, forms, and other content for toggling -->
                        <div>
                            <div >
                                <ul class="nav navbar-nav" style=" width: 20%;">

                                    <li class="notice">


                                        <div class='popbox'>

                                            <div  style="text-align: center;" class='open'  >
                                                <span  class="glyphicon glyphicon-user"><span id="request" class="badge"></span></span>
                                            </div>


                                            <div class='collapse-one'>
                                                <div class='box' >
                                                    <div class='arrow'></div>
                                                    <div class='arrow-border'></div>

                                                    <div class="popbox-content">
                                                        <div class="popbox-header">Yêu cầu kết bạn</div>
                                                        <div class="popbox-data">
                                                            <ul id="friend-request">

                                                            </ul>
                                                        </div>
                                                        <div class="popbox-footer">
                                                            <a href="#">Xem tất cả</a>
                                                        </div>
                                                    </div>
                                                    

                                                </div>
                                            </div>
                                        </div>



                                    </li>
                                    <li class="notice">
                                        <a class='open' data-toggle="modal" data-target="#inbox">
                                            <span class="glyphicon glyphicon-comment"><span id="count-message" class="badge"></span></span>
                                        </a>
                                    </li>
                                    <li class="notice">


                                        <div class='popbox' >
                                            <div  style="text-align: center;" class='open'  >

                                                <span class="glyphicon glyphicon-exclamation-sign"></span>

                                            </div>

                                            <div class='collapse-one'>
                                                <div class='box' >
                                                    <div class='arrow'></div>
                                                    <div class='arrow-border'></div>

                                                    <div class="popbox-content">
                                                        <div class="popbox-header">Bảng tin</div>
                                                        <div class="popbox-data"></div>
                                                        <div class="popbox-footer">
                                                            <a href="#">Xem tất cả</a>
                                                        </div>
                                                    </div>


                                                </div>
                                            </div>
                                        </div>

                                    </li>

                                </ul>
                            </div>
                            <div style="height: 0;" >
                                <form id="sb"  style="padding-top: 0.7%;" method="get" action="http://localhost:8080/nfa/index.php/search/searchquick">
                                    <div class="input-group" style="width:40%;">
                                        <input autocomplete="off" type="text"  id="keywords" name="kw"  class="form-control" placeholder="Tìm kiếm tên hoặc email ...." />
                                        <span class="input-group-btn">
                                            <button id="btn-search" class="btn btn-success" type="submit">Tìm kiếm</button>
                                        </span>
                                    </div>
                                    <div  id="results" style="width:40%; margin-left: 28%;">

                                    </div>


                                </form><!-- /.col-lg-6 -->
                            </div>
                            <div style="float: right;">
                                <ul class="nav navbar-nav" >
                                    <?php if ($this->session->userdata('email')) { ?>
                                        <li class="notice"><a href="http://localhost:8080/nfa/index.php/home/mypage"><img src="http://localhost:8080/nfa/images/avarta/<?php echo $anh; ?>" class="notice-area"  /> <?php echo $ten; ?></a></li>
                                    <?php } else { ?>
                                        <li class="notice"><a href="http://localhost:8080/nfa/index.php/home/mypage"><img src="http://localhost:8080/nfa/images/avarta/user_male4.png" class="notice-area"  /> <?php echo $ten; ?></a></li>

                                    <?php } ?> 
                                    <li class="notice">
                                        <a href="http://localhost:8080/nfa/index.php/home">Home</a>
                                    </li>
                                    <li class="dropdown notice">
                                        <a href="#" class="dropdown-toggle" data-toggle="dropdown"><span class="glyphicon glyphicon-cog"></span> <b class="caret"></b></a>
                                        <ul class="dropdown-menu">
                                            <li><a href="">Thiết lập</a></li>
                                            <li><a href="http://localhost:8080/nfa/index.php/login/logout">Thoát</a></li>

                                        </ul>
                                    </li>

                                </ul>
                            </div>
                        </div><!-- /.navbar-collapse -->
                    </div><!-- /.container-fluid -->
                </div>
            </nav>
        </header>

        <!-- message -->
        <div class="modal fade" id="inbox" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
            <div class="modal-dialog modal-lg">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                        <h4 class="modal-title" id="myModalLabel"> Tin nhắn</h4>
                    </div>

                    <div class="modal-body">
                        <div class="row">
                            <div class="col-xs-6 col-md-4" style="overflow : auto;" >
                                <ul id="coversations" class="list-group">

                                </ul>
                                <p id="typing"></p>
                            </div>
                            <div class="col-xs-12 col-md-8">
                                <div class="panel panel-default">
                                    <div class="panel-body" id="ob" style="height: 380px; overflow : auto;" >
                                        <ul id="tinnhan">

                                        </ul>
                                    </div>
                                    <div class="panel-footer" >
                                        <form id="chat-box" method="post">

                                            <input type="hidden" name="id" value="" id="id-chat"/>
                                            <textarea name="chat" id="chatchit" class="form-control"   rows="3"></textarea> 

                                        </form>

                                    </div>
                                </div>
                                <p style="float: right; font-weight: bold;"><span class="glyphicon glyphicon-ok-circle"></span> Nhấn enter để gửi</p>
                            </div>
                        </div>
                    </div>


                </div>
            </div>
        </div>

        <!-- create new dating -->

        <div class="modal fade" id="newdating" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
            <div class="modal-dialog modal-lg">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                        <h4 class="modal-title" id="myModalLabel"> Cuộc hẹn mới</h4>
                    </div>
                    <form id="createdating" method="post" role="form">
                        <div class="modal-body" style="height: 350px;">
                            <div class="form-group" style="margin-bottom: 6%;">
                                <label for="input1" class="col-sm-2 control-label"> Tên cuộc hẹn :</label>
                                <div class="col-sm-10">
                                    <input type="text" class="required  form-control" id="input1" name="namedating" placeholder="Tên cuộc hẹn">
                                </div>
                            </div>
                            <div  class="form-group" >
                                <div class="radio-inline">
                                    <label>Thời gian hẹn :</label>
                                </div>
                                <div class="radio-inline">

                                    <input type="text" class="required  form-control" id="datepicker" name="date" placeholder="Ngày hẹn (bắt buộc)" />
                                </div>
                                <div class=" radio-inline">
                                    <select name="hours" class="number form-control">
                                        <option>Giờ</option>
                                        <?php for ($y = 1; $y <= 24; $y++) { ?>


                                            <option><?php echo $y; ?></option>
                                        <?php } ?>
                                    </select>
                                </div>
                                <div class=" radio-inline">
                                    <select name="minute" class="number form-control">
                                        <option> Phút </option>
                                        <option>00</option>
                                        <option>15</option>
                                        <option>30</option>
                                        <option>45</option>
                                    </select>
                                </div>
                            </div>
                            <div class="form-group" style="padding-bottom: 8%;">
                                <label for="input3" class="col-sm-2 control-label">Mô tả :</label>
                                <div class="col-sm-10">
                                    <textarea name="description" class="required form-control" id="input3" rows="3" placeholder="Mô tả(bắt buộc)"></textarea>
                                </div>
                            </div>
                            <div  class="form-group" style="">
                                <div class="radio-inline">
                                    <label> Muốn Hẹn với:</label>
                                </div>

                                <div class="radio-inline" style="margin-left: 4%;">
                                    <label>
                                        <input type="radio" name="gender" id="optionsRadios1" value="Nam" checked>
                                            Nam
                                    </label>
                                </div>
                                <div class="radio-inline">
                                    <label>
                                        <input type="radio" name="gender" id="optionsRadios2" value="Nữ">
                                            Nữ 
                                    </label>
                                </div>
                                <div class="radio-inline">
                                    <label>
                                        <input type="radio" name="gender" id="optionsRadios3" value="Gay">
                                            Gay 
                                    </label>
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="input4" class="col-sm-2 control-label">Địa điểm</label>
                                <div class="col-sm-10">
                                    <textarea name="address" class=" form-control" id="input4" rows="3" placeholder="Địa điểm hẹn " ></textarea>
                                </div>
                            </div>




                        </div>

                        <div class="modal-footer">
                            <button id="" type="submit" class="btn btn-success" style="float:left; " >Hoàn Tất </button>
                            <button id="" data-dismiss="modal" class="btn btn-warning">Trở về </button>
                        </div>
                    </form>

                </div>
            </div>
        </div>

        <div class="center">
            <div class="row" style="padding-top:6%;">
                <div class="col-xs-4 col-md-3">
                    <div class="panel panel-info" >
                        <div class="panel-body" 
                            <center>
                                <div style="border-bottom: 1px #0480be solid; padding-bottom: 6%;">
                                    <h4 style="color: #0069D6;">TÌM KIẾM CUỘC HẸN</h4>
                                </div>
                            </center>
                           
                             <form id="searchdating" method="post" action="<?php echo base_url("dating/searchdating"); ?>" >
                               
                            <div style="padding-top: 4%;">
                                <div class="radio-inline">
                                    <label>Hẹn với:</label>
                                </div>

                                <div class="radio-inline" >
                                    <label>
                                        <input type="radio" name="gender" id="optionsRadios1" value="Nam" checked>
                                            Nam
                                    </label>
                                </div>
                                <div class="radio-inline">
                                    <label>
                                        <input type="radio" name="gender" id="optionsRadios2" value="Nữ">
                                            Nữ 
                                    </label>
                                </div>
                                
                            </div >
                            
                            <div style="padding-top: 4%;"> 
                             <select name="city" class="form-control" placeholder="Thành phố"  >
                                            <option>Chọn thành phố</option>
                                            <option>Hà Nội</option>
                                            <option>TP.Hồ Chí Minh</option>
                                            <option>Đà Nẵng</option>
                                            <option> Huế </option>
                                            <option> Dak Lak</option>
                             </select>
                            </div>
                            <div style="padding-top: 4%;" >
                               <input type="text" class="form-control" id="frompicker" name="from" placeholder="Từ ngày" />
                            </div>
                            <div style="padding-top: 4%;" >
                               <input type="text" class="form-control" id="topicker" name="to" placeholder="Đến ngày" />
                            </div>
                            <div style="padding-top: 5%;" >
                                <center>
                                    <button class="btn btn-success" type="submit"><span class="glyphicon glyphicon-search"></span> Tìm kiếm </button>
                                </center>
                            </div>
                            </form>
                            
                        </div>
                    </div>
                </div>

                <div class="col-xs-17 col-md-9">

                    <div class="panel panel-info" >

                        <div class="panel-body">
                            <div style="padding-left: 2%; padding-right: 2%; border-bottom: 1px #F06 solid; height:60px;">
                                <div style="float: left;">
                                    <h3 >DANH SÁCH CUỘC HẸN</h3>
                                </div>
                                <div style="float: right;">
                                    <button class="btn btn-primary" data-toggle="modal" data-target="#newdating"  ><span class=" glyphicon glyphicon-asterisk"></span>Tạo cuộc hẹn</button>
                                </div>
                            </div>
                            <div >
                                <ul>
                                    <?php
                                    $a = $this->connect->getfirstdating();
                                    foreach ($a as $i) {
                                        $id_dating = $i->dating_id;
                                        $id_create = $i->user_id1;
                                        $datingname = $i->dating_name;
                                        $description = $i->description;
                                        $target = $i->target;
                                        $date = $i->date_dating;
                                        $hours = $i->hours;
                                        $minute = $i->minute;
                                        $address = $i->address;

                                        $time = date("d-m-Y", strtotime($date));
                                        $b = $this->connect->getID($id_create);
                                        foreach ($b as $z) {
                                            $avarta = $z->avarta;
                                            $name = $z->name;
                                            $old = $z->age;
                                            $thanhpho =$z->city;
                                        }
                                        ?>

                                        <li class="dating" >
                                            <div style="float: left; width: 10%;">
                                                <a href="<?php
                                                if ($id_create == $this->session->userdata('id')) {
                                                    echo base_url("home/mypage");
                                                } else {
                                                    echo base_url("getid?id=" . $id_create);
                                                }
                                                ?>
                                                   ">
                                                    <img class='anhnho4  img-thumbnail' src="http://localhost:8080/nfa/images/avarta/<?php echo $avarta; ?>" />
                                                </a>
                                            </div>
                                            <div style="float: left; width: 40%; padding-left: 2%;">
                                                <a class="open"><?php echo $datingname; ?></a> <br/>
                                                <b> Hẹn bởi :</b><?php echo $name; ?>,<?php echo $old; ?> tuổi <br/>

                                                <b> Hẹn với : </b><?php echo $target; ?> <br/>
                                                <b>Mô tả : </b> <p class="short-text"><?php echo $description; ?> </p>


                                            </div>
                                            <div style="float: left; width: 35%;">
                                                <b> Thời gian :</b> <?php echo $hours; ?> giờ <?php echo $minute; ?> phút.<br/>
                                                <b>Ngày :</b> <?php echo $time; ?> <br/>
                                                <b> Địa điểm hẹn : <?php echo $address; ?> - <?php echo $thanhpho; ?> </b>

                                            </div>
                                            <div style="float: left; width: 10%;">
                                                <a class="btn btn-warning" href="<?php echo base_url('dating/getdating?id='.$id_dating);?>">Xem chi tiết</a>
                                            </div>

                                        </li>
                                        <?php
                                    }
                                    ?>
                                </ul>
                                
                                <input type="hidden" id="page" value="4"/>
                                <ul id="dating-list">

                                </ul>
                                <div id="ajax-loading" style="text-align: center; display: none">
                                    <center><img src="http://localhost:8080/nfa/images/ajax-loading.gif" /></center>
                                </div>
                            </div>

                        </div>
                    </div>
                </div>

            </div>









        </div>





    </body>

</html>
<script type="text/javascript">
            $(window).scroll(function(){
                var id = $("#page").val();
                
        if ($(window).scrollTop() == $(document).height() - $(window).height())
                {
                    $('#ajax-loading').show();
                    $.ajax({
                        url: "http://localhost:8080/nfa/index.php/dating/loadmore",
                        type: "POST",
                        data: {
                            id: id
                        },
                        success: function(html)
                        {
                            if (html)
                            {
                                setTimeout(500);
                                  var kq = 4 + parseInt(id);
                                $("#dating-list").append(html);
                                $('#ajax-loading').hide();
                                $('#page').attr('value',kq);
                                console.log(kq);
                            } else
                            {
                                $('#ajax-loading').html('<center>Không còn dữ liệu.</center>');
                            }
                        }
                    });
                }
            });
            function cleanphoto() {
                $(".photo").empty();
            }

            function zoomphoto(id) {

                $.ajax({
                    url: "http://localhost:8080/nfa/index.php/photo/getphoto",
                    type: "POST",
                    data: {
                        id: id
                    },
                    success: function(data) {
                        $(".photo").html(data);


                    }
                });



            }
            function loadphoto(id) {
                $.ajax({
                    url: "http://localhost:8080/nfa/index.php/photo/loadphoto",
                    type: "POST",
                    data: {
                        id: id
                    },
                    success: function(data) {
                        $("#loadphoto").html(data);

                    }
                });

            }
            function deletephoto(id) {
                $.ajax({
                    url: "http://localhost:8080/nfa/index.php/photo/deletephoto",
                    type: "POST",
                    data: {
                        id: id
                    },
                    success: function(data) {

                    }
                });

            }
            function deletealbum(id) {
                $.ajax({
                    url: "http://localhost:8080/nfa/index.php/photo/deletealbum",
                    type: "POST",
                    data: {
                        id: id
                    },
                    success: function(data) {
                        window.location = "http://localhost:8080/nfa/index.php/home/mypage";
                    }
                });

            }

            function  getbutton() {

                var id = $("#user-id").val();
                $.ajax({
                    url: 'http://localhost:8080/nfa/index.php/friend/getbutton', // form action url
                    type: 'POST', // form submit method get/post
                    dataType: 'html', // request type html/json/xml
                    data: {id: id}, // serialize form data 

                    success: function(data) {
                        $("#btn-friend").html(data);
                    },
                    error: function(e) {
                        console.log(e);
                    }

                });
                setTimeout('getbutton()', 500);

            }

            function  agree(id) {


                $.ajax({
                    url: 'http://localhost:8080/nfa/index.php/friend/agree', // form action url
                    type: 'POST', // form submit method get/post
                    dataType: 'html', // request type html/json/xml
                    data: {id: id}, // serialize form data 

                    success: function(data) {

                    },
                    error: function(e) {
                        console.log(e);
                    }

                });

            }
            var myvar;

            function updateRequest() {
                $.ajax({
                    url: "http://localhost:8080/nfa/index.php/friend/checkrequest",
                    success: function(data) {
                        $("#request").empty();
                        $("#request").append(data);


                        // Do something similar for unreadMessages, if required...
                    }
                });
                setTimeout('updateRequest()', 1000); // Every 15 seconds.
            }
            function getRequest() {
                $.ajax({
                    url: "http://localhost:8080/nfa/index.php/friend/getrequest",
                    success: function(data) {
                        $("#friend-request").empty();
                        $("#friend-request").append(data);


                        // Do something similar for unreadMessages, if required...
                    }
                });
                setTimeout('getRequest()', 500); // Every 15 seconds.
            }

            function updateAlerts() {
                $.ajax({
                    url: "http://localhost:8080/nfa/index.php/message/checkmessage",
                    success: function(data) {
                        $("#count-message").empty();
                        $("#count-message").append(data);


                        // Do something similar for unreadMessages, if required...
                    }
                });
                setTimeout('updateAlerts()', 1000); // Every 15 seconds.

            }
            function updateconversations() {
                $.ajax({
                    url: "http://localhost:8080/nfa/index.php/message/getconversations",
                    success: function(data) {
                        $("#coversations").empty();
                        $("#coversations").append(data);


                        // Do something similar for unreadMessages, if required...
                    }
                });
                setTimeout('updateconversations()', 500); // Every 15 seconds.

            }

            function updatemessage(id) {

                $.ajax({
                    url: "http://localhost:8080/nfa/index.php/message/getmessage",
                    type: "POST",
                    data: {
                        id: id
                    },
                    success: function(data) {
                        $("#tinnhan").html(data);
                        $("#id-chat").val(id);

                    }
                });
                myvar = setTimeout(function() {
                    updatemessage(id);
                }, 500);
                ;


            }
            function myStopFunction() {
                clearTimeout(myvar);
            }
            function updatestt(id) {

                $.ajax({
                    url: "http://localhost:8080/nfa/index.php/message/updatestt",
                    type: "POST",
                    data: {
                        id: id
                    },
                    success: function(data) {


                        //
                        // Do something similar for unreadMessages, if required...
                    }
                });

            }



</script>
